home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_01_01 / 1n01047a < prev    next >
Text File  |  1990-05-16  |  2KB  |  82 lines

  1. *****Listing 1*****
  2.  
  3. #include    <graphics.h>
  4.  
  5. extern    void (*fill_box_call);
  6. extern    void (*outtextxy_call);
  7. extern    void (*putpixel_call);
  8. extern    void (*line_call);
  9.  
  10. extern    struct viewport v;
  11. extern    int        output_location;
  12. extern    int        text_width;
  13. extern    int        text_height;
  14.  
  15. #define    SCREEN        0
  16. #define    PORTRAIT    1
  17. #define    LANDSCAPE    2
  18.  
  19. /************************************************************
  20. *    setup_device() - set output parameters
  21. *
  22. *    Parameters:
  23. *        device (in) - SCREEN, PORTRAIT (printer), or
  24. *                      LANDSCAPE (printer)
  25. *    Notes:
  26. *        1.    The sample code was done using Turbo C version 2.0
  27. *
  28. *    History
  29. *        Original code William Roetzheim, 1990
  30. *************************************************************/
  31.  
  32. void setup_device(int device)
  33. {
  34.     void    fill_box();
  35.     void    outtextxy();
  36.     void    line();
  37.     void    putpixel();
  38.     void    lj_fill_box();
  39.     void    lj_outtextxy();
  40.     void    lj_line();
  41.     void    lj_putpixel();
  42.     struct    viewporttype    vp;     /* used for screen only */
  43.  
  44.     switch (device)
  45.     {
  46.         case SCREEN:
  47.             fill_box_call = fill_box;
  48.             outtextxy_call = outtextxy;
  49.             line_call = line;
  50.             putpixel_call = putpixel;
  51.             text_width = 8;
  52.             text_height = 10;    /* allow for spaces between lines */
  53.             getviewsettings(&vp);
  54.             v.left = vp.left;
  55.             v.top = vp.top;
  56.             v.right = vp.right;
  57.             v.bottom = vp.bottom;
  58.             break;
  59.  
  60.         case PORTRAIT:
  61.         case LANDSCAPE:
  62.             fill_box_call = lj_fill_box;
  63.             outtextxy_call = lj_outtextxy;
  64.             putpixel_call = lj_putpixel;
  65.             v.left = 0;
  66.             v.top = 0;
  67.             if (device == LANDSCAPE)
  68.             {
  69.                 v.right = 3179;
  70.                 v.bottom = 2249;
  71.             }
  72.             else
  73.             {
  74.                 v.right = 2249;
  75.                 v.bottom = 3179;
  76.             }
  77.             break;
  78.     }
  79.     output_location = device;
  80. }
  81.  
  82.